package com.yang.design.create.singletonPattern;


/**
 * 懒汉式-单例
 */
public class Single02 {

    private volatile static Single02 instance;

    private Single02(){}

    public  static Single02 getInstance(){
        if (instance == null) {
            synchronized (Single02.class) {
                if (instance == null) {
                    //1.分配内存空间 2.初始化 3.引用指向  //1.3.2
                    instance = new Single02();
                }
            }
        }
        return instance;
    }
}
